package org.leon.mapper;

import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.leon.pojo.Order;
import org.leon.pojo.User;

import java.util.List;


public interface OrderMapper {

    List<Order> getAllOrders();

    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "orderTime", column = "order_time"),
            @Result(property = "total", column = "total"),
            @Result(property = "user", column = "uid", javaType = User.class,
                    one = @One(select = "org.leon.mapper.UserMapper.findById"))
    })
    @Select("select id, order_time, total, uid from t_order")
    List<Order> getOrderWithUser();

    @Select("select id, order_time, total from t_order where uid=#{id}")
    List<Order> findOrderByUserId(Integer uid);
}
